package reader.contorller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reader.entity.Evaluation;
import reader.service.EvaluationService;
import reader.utils.ResponseUtils;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/evaluation")
public class EvaluationController {
    @Autowired
    private EvaluationService evaluationService;

    @GetMapping("/id/{id}")
    public ResponseUtils findById(@PathVariable("id") Long id) {
        ResponseUtils response = null;
        try {
            List<Map> maps = evaluationService.selectByBookId(id);
            response = new ResponseUtils().put("list",maps);
        }catch (Exception e) {
            e.printStackTrace();
            response = new ResponseUtils("error",e.getMessage());
        }
    return response;
    }

}
